.class public Llt/noframe/gpsfarmguide/states/start_stop_gps_states/StopGps;
.super Ljava/lang/Object;
.source "StopGps.java"

# interfaces
.implements Llt/noframe/gpsfarmguide/states/start_stop_gps_states/StartStopGps;


# direct methods
.method public constructor <init>()V
    .locals 3

    .line 23
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 24
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getStartStopGpsController()Llt/noframe/gpsfarmguide/states/start_stop_gps_states/StartStopGpsController;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/states/start_stop_gps_states/StartStopGpsController;->getButton()Landroid/widget/ImageView;

    move-result-object v0

    const v1, 0x7f080165

    invoke-virtual {v0, v1}, Landroid/widget/ImageView;->setImageResource(I)V

    .line 25
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getStartStopGpsController()Llt/noframe/gpsfarmguide/states/start_stop_gps_states/StartStopGpsController;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/states/start_stop_gps_states/StartStopGpsController;->getText()Landroid/widget/TextView;

    move-result-object v0

    invoke-static {}, Llt/noframe/gpsfarmguide/App;->getContext()Landroid/content/Context;

    move-result-object v1

    const v2, 0x7f1101da

    invoke-virtual {v1, v2}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    return-void
.end method


# virtual methods
.method public doAction()V
    .locals 6

    .line 30
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    const/4 v1, 0x3

    if-le v0, v1, :cond_3

    .line 31
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getMap()Lcom/google/android/gms/maps/GoogleMap;

    move-result-object v0

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Lcom/google/android/gms/maps/GoogleMap;->setOnMyLocationChangeListener(Lcom/google/android/gms/maps/GoogleMap$OnMyLocationChangeListener;)V

    .line 32
    new-instance v0, Llt/noframe/gpsfarmguide/gui/GuiFactory;

    invoke-direct {v0}, Llt/noframe/gpsfarmguide/gui/GuiFactory;-><init>()V

    .line 35
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v2

    invoke-virtual {v2}, Llt/noframe/gpsfarmguide/Data;->getTool()I

    move-result v2

    const/4 v3, 0x1

    if-eq v2, v3, :cond_2

    const/4 v4, 0x2

    if-eq v2, v4, :cond_0

    goto :goto_0

    .line 41
    :cond_0
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v1

    invoke-virtual {v1}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v1

    invoke-virtual {v1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v1

    .line 42
    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v2

    rem-int/2addr v2, v4

    if-eqz v2, :cond_1

    .line 43
    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v2

    sub-int/2addr v2, v3

    invoke-interface {v1, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/google/android/gms/maps/model/LatLng;

    const/4 v5, 0x0

    invoke-interface {v1, v5}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lcom/google/android/gms/maps/model/LatLng;

    invoke-static {v2, v5}, Llt/noframe/gpsfarmguide/utils/Mathematics;->getMidPoint(Lcom/google/android/gms/maps/model/LatLng;Lcom/google/android/gms/maps/model/LatLng;)Lcom/google/android/gms/maps/model/LatLng;

    move-result-object v2

    invoke-interface {v1, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 44
    :cond_1
    new-instance v2, Llt/noframe/gpsfarmguide/models/MeasuringModel;

    new-instance v5, Llt/noframe/gpsfarmguide/models/PolygonModel;

    invoke-direct {v5, v1}, Llt/noframe/gpsfarmguide/models/PolygonModel;-><init>(Ljava/util/List;)V

    invoke-direct {v2, v5, v4, v3}, Llt/noframe/gpsfarmguide/models/MeasuringModel;-><init>(Llt/noframe/gpsfarmguide/interfaces/Shape;IZ)V

    .line 45
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v1

    invoke-virtual {v1}, Llt/noframe/gpsfarmguide/Data;->getMapStatesController()Llt/noframe/gpsfarmguide/states/map_states/MapStatesController;

    move-result-object v1

    new-instance v4, Llt/noframe/gpsfarmguide/states/map_states/AreaDrawingState;

    invoke-direct {v4}, Llt/noframe/gpsfarmguide/states/map_states/AreaDrawingState;-><init>()V

    invoke-virtual {v1, v4}, Llt/noframe/gpsfarmguide/states/map_states/MapStatesController;->setCurrentState(Llt/noframe/gpsfarmguide/states/map_states/MapState;)V

    move-object v1, v2

    goto :goto_0

    .line 37
    :cond_2
    new-instance v1, Llt/noframe/gpsfarmguide/models/MeasuringModel;

    new-instance v2, Llt/noframe/gpsfarmguide/models/LineModel;

    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v4

    invoke-virtual {v4}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v4

    invoke-virtual {v4}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v4

    invoke-direct {v2, v4}, Llt/noframe/gpsfarmguide/models/LineModel;-><init>(Ljava/util/List;)V

    invoke-direct {v1, v2, v3, v3}, Llt/noframe/gpsfarmguide/models/MeasuringModel;-><init>(Llt/noframe/gpsfarmguide/interfaces/Shape;IZ)V

    .line 38
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v2

    invoke-virtual {v2}, Llt/noframe/gpsfarmguide/Data;->getMapStatesController()Llt/noframe/gpsfarmguide/states/map_states/MapStatesController;

    move-result-object v2

    new-instance v4, Llt/noframe/gpsfarmguide/states/map_states/DistanceDrawingState;

    invoke-direct {v4}, Llt/noframe/gpsfarmguide/states/map_states/DistanceDrawingState;-><init>()V

    invoke-virtual {v2, v4}, Llt/noframe/gpsfarmguide/states/map_states/MapStatesController;->setCurrentState(Llt/noframe/gpsfarmguide/states/map_states/MapState;)V

    .line 53
    :goto_0
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v2

    invoke-virtual {v2}, Llt/noframe/gpsfarmguide/Data;->getGui()Llt/noframe/gpsfarmguide/gui/Gui;

    move-result-object v2

    invoke-interface {v2}, Llt/noframe/gpsfarmguide/gui/Gui;->clearGuiWithMeasure()V

    if-eqz v1, :cond_4

    .line 55
    invoke-virtual {v0, v3, v1}, Llt/noframe/gpsfarmguide/gui/GuiFactory;->buildGui(ILlt/noframe/gpsfarmguide/models/MeasuringModel;)V

    goto :goto_1

    .line 57
    :cond_3
    invoke-static {}, Llt/noframe/gpsfarmguide/App;->getContext()Landroid/content/Context;

    move-result-object v0

    invoke-static {v0}, Llt/noframe/gpsfarmguide/dialogs/ErrorDialogs;->notEnoughPoints(Landroid/content/Context;)V

    :cond_4
    :goto_1
    return-void
.end method
